package Doudizhu;

import java.util.*;

/**
 * 斗地主
 */
public class Doudizhu {

    private List poker = new ArrayList(); //底牌
    private List palyer1 = new ArrayList(); //玩家1
    private List palyer2 = new ArrayList();  //玩家2
    private List palyer3 = new ArrayList();  //玩家3
    private List hand = new ArrayList();//底牌

    public void init() {  //扑克初始化
        for (int i = 1; i <= 14; i++) {  //遍历，分别给52张牌附上不同的花色
            poker.add(new Card("♣", Integer.toString(i), i));
            poker.add(new Card("♥", Integer.toString(i), 13 + i));
            poker.add(new Card("♦", Integer.toString(i), 26 + i));
            poker.add(new Card("♠", Integer.toString(i), 39 + i));
        }
        poker.add(new Card("", "大王", 53));  //把大王放在53张
        poker.add(new Card("", "小王", 54));  //把小王放在54张


    }

    public void xipai() {  //洗牌
        Collections.shuffle(poker);


    }

    public void faPai() { //发牌
        palyer1 = poker.subList(0, 17); //玩家1发牌
        palyer2 = poker.subList(17, 34); //玩家2发牌
        palyer3 = poker.subList(34, 51); //玩家3发牌
        hand = poker.subList(51, 54);  //底牌三张
        System.out.println("玩家1" + palyer1);
        System.out.println("玩家2" + palyer2);
        System.out.println("玩家3" + palyer3);
        System.out.println("底牌" + hand);


    }


    public static void main(String[] args) {
        //测试
        Doudizhu doudizhu = new Doudizhu();
        doudizhu.init();
        doudizhu.xipai();
        doudizhu.faPai();

    }

}
